//
//  VKJiFenShopPayCell.m
//  V-Learn
//
//  Created by liubo on 2019/1/9.
//  Copyright © 2019 yxk. All rights reserved.
//

#import "VKJiFenShopPayCell.h"

@implementation VKJiFenShopPayCell{
    UILabel *_leftLabel;
    UITextField *_rightTf;
}

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    VKJiFenShopPayCell *cell = [tableView dequeueReusableCellWithIdentifier:@"VKJiFenShopPayCell"];
    if (cell == nil) {
        cell = [[VKJiFenShopPayCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"VKJiFenShopPayCell"];
    }
    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    return cell;
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // 点击cell的时候不要变色
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        // 布局子控件
        [self autoLayout];
    }
    return self;
}

-(void)setModel:(VKJiFenShopPayModel *)model{
    _model = model;
    _leftLabel.text = model.leftStr;
    _rightTf.placeholder = model.placeHoldStr;
    _rightTf.tag = model.row + 2000;
}

- (void)autoLayout{
    
    UILabel *leftLabel = [[UILabel alloc]init];
    _leftLabel = leftLabel;
    [self.contentView addSubview:leftLabel];
    leftLabel.font = [UIFont systemFontOfSize:17];
    leftLabel.textColor = [UIColor cz_colorWithRed:40 green:40 blue:40];
    [leftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView).offset(15);
        make.centerY.mas_equalTo(self.contentView);
        make.width.equalTo(@100);
    }];
    UILabel *lineLabel = [[UILabel alloc]init];
    [self.contentView addSubview:lineLabel];
    lineLabel.backgroundColor = [UIColor cz_colorWithRed:210 green:210 blue:210];
    [lineLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView).offset(15);
        make.right.equalTo(@(-15));
        make.height.equalTo(@0.5);
        make.bottom.mas_equalTo(self.contentView);
    }];
    
    UITextField *rightTf = [[UITextField alloc]init];
    _rightTf = rightTf;
    rightTf.userInteractionEnabled = YES;
    [self.contentView addSubview:rightTf];
    [rightTf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(leftLabel.mas_right).offset(10);
        make.centerY.equalTo(leftLabel);
        make.right.mas_equalTo(-15);
        make.top.bottom.equalTo(leftLabel);
        make.width.equalTo(@([UIScreen cz_screenWidth] - 25 - CGRectGetMaxX(leftLabel.frame)));
    }];

}
@end
